#include "stm32f4xx_hal.h"
#include "stm32f4xx_ll_rcc.h"
#include "stdio.h"

#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"

#include "DevicesQueue.h"
#include "DevicesKey.h"

#include "taskKey.h"


/* 按键处理任务句柄 */
TaskHandle_t g_TaskKeyHand = NULL;


void vTaskKey(void *pvParameters)
{
    KeyTypeDef typeKeyData = {0};

    while(1)
    {
        ulTaskNotifyTake(pdTRUE, portMAX_DELAY);

        /* Key 触发的键值 */
        while(enumQueuePopDatas(&g_TypeQueueKeyInput, &typeKeyData, sizeof(KeyTypeDef)) == queueNormal)
        {
            /* 短按，并已松开 */
            if(typeKeyData.state == (keyShort | keyCut))
            {
                if(typeKeyData.valueLoosen & KEY_UP)
                {

                }
            }
            /* 长按，还未松开 */
            else if(typeKeyData.state == keyLong)
            {
                if(typeKeyData.valuePress & KEY_DOWN)
                {
                }
            }
        }
    }
}
